home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / GTBKCLR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  761 b   |  27 lines

  1. #include <graphics.h>
  2. #include <stdlib.h>
  3.  
  4. main()
  5. {
  6.    int graphdriver = DETECT, graphmode;
  7.    int bcolor, maxcolor;
  8.  
  9. /* Initialize the graphics system */
  10.    initgraph(&graphdriver, &graphmode, "c:\\turboc");
  11. /* Get current background color and save it */
  12.    bcolor = getbkcolor();
  13. /* Now keep switching background colors randomly */
  14.    maxcolor = getmaxcolor();
  15.    randomize(); /* Initialize random number generator */
  16.    outtextxy(10,20, "Press any key to exit");
  17.    while (!kbhit())
  18.    {
  19.       setbkcolor(random(maxcolor));
  20.       delay(1000);  /* Pause for 1 second */
  21.    }
  22. /* Wait for 1 second, then restore previous color */
  23.    delay(1000);
  24.    setbkcolor(bcolor);
  25.    delay(1000);  /* Let user see the change */
  26.    closegraph();
  27. }